#[test]
fn test_macro() {
  let rt = tools::global_defin::tokio_runtime::get_rt();
  let _rt_guard = rt.enter();
  let _log = tools::global_defin::trace_log::init_tracing_log();

  let pool = persistence::sqlx_p::sqlx_pool();

  let s = rt.spawn(async move {
    // let mut conn = <impl sqlx::Executor>;
    let account = persistence::query_one!(
      Account,
      pool,
      "select platform_id as id,platform_name as name from t_sys_platform 
			 where platform_id = $1 and description = $2",
      1i32,
      "镇江移动"
    );
    println!("{account:?}");

    let value = persistence::query_value!(
      pool,
      "select platform_name as name from t_sys_platform 
			 where platform_id = $1 ",
      String::default(),
      2i32
    );
    println!("{value:?}");
  });

  while !s.is_finished() {
    std::thread::sleep(std::time::Duration::from_secs(1));
  }

  // println!("{}: {}", account.id, account.name);
}

#[derive(Debug)]
struct Account {
  id: i32,
  name: String,
}
use sqlx::{FromRow, Row};
impl FromRow<'_, sqlx::postgres::PgRow> for Account {
  fn from_row(row: &'_ sqlx::postgres::PgRow) -> Result<Self, sqlx::Error> {
    Ok(Account {
      id: row.try_get(0).unwrap_or(0),
      name: row.try_get(1).unwrap_or(Default::default()),
    })
  }
}
